#!/user/bin/env python
# -*- coding: utf-8 -*-
''' 
Author: Sjy
LastEditTime: 2024-09-11 09:32:42
Description: 封装定时器功能
'''

__all__= []

from PyQt5 import QtCore
import types

def create_once(action, delay:int=10):
    """创建一个一次性定时器"""

    
    timer = QtCore.QTimer()
    def run(*args, **kwargs):
        action()
        timer.stop()
    timer.setSingleShot(True) # 只执行一次
    timer.timeout.connect(run)
    timer.start(delay) # 设置延迟时间，单位为毫秒
    print("定时器已启动")


